package com.atguigu.tingshu.account.rpc;

import com.atguigu.tingshu.account.service.UserAccountService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.account.RechargeInfo;
import com.atguigu.tingshu.vo.account.AccountLockResultVo;
import com.atguigu.tingshu.vo.account.AccountLockVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.lang.annotation.Retention;

@RestController
@RequestMapping("rpc/inner/accountInfo")
public class UserAccountRpcController {
    @Autowired
    private UserAccountService userAccountService;

    @PostMapping("/checkAndLockAmount")
    Result<AccountLockResultVo> checkAndLockAmount(@RequestBody AccountLockVo accountLockVo){

        return userAccountService.checkAndLockAmount(accountLockVo);
    }

    @PostMapping("/getRechargeInfoByOrderNo/{orderNo}/{userId}")
    Result<RechargeInfo> getRechargeInfoByOrderNo(@PathVariable(value = "orderNo") String orderNo, @PathVariable(value = "userId") Long userId){

        RechargeInfo rechargeInfo = userAccountService.getRechargeInfoByOrderNo(orderNo,userId);

        return Result.ok(rechargeInfo);
    }
}
